# syntax=docker/dockerfile:1
FROM golang:alpine as build
# docker镜像内部程序工作目录
WORKDIR /src
RUN mkdir /app

# 构建时需要指定构建ginfwk的位置
# eg: docker build /data/release/ginfwk
COPY . /src/

# 环境变量
ENV GO111MODULE=on \
    CGO_ENABLED=0 \
    GOOS=linux \
    GOARCH=amd64
# 阿里: https://mirrors.aliyun.com/goproxy/
RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct

# 开始构建
RUN go mod tidy
RUN go build -o /app/main server/main.go

# 运行
FROM alpine AS api
WORKDIR /app
COPY --from=build /app/main /app/
COPY --from=build /src/server/config/config-prod.yaml /app/

EXPOSE 8082
ENTRYPOINT ["/app/main", "-c" ,"/app/config-prod.yaml"]